package com.group.transaction.controller;

import com.group.transaction.aspect.InMethod;
import com.group.transaction.domain.User;
import com.group.transaction.model.ResultJson;
import com.group.transaction.service.integral.IntegralService;
import org.apache.shiro.SecurityUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/integral")
public class IntegralController {

    @Resource
    private IntegralService integralService;

    @GetMapping("/selectUserIntegral")
    @InMethod(apiName = "获取积分")
    public ResultJson selectUserIntegral() {
        return integralService.findUserInegral();
    }

    @GetMapping("/findUserInegralByUserId")
    @InMethod(apiName = "获取用户积分")
    public ResultJson findUserInegralByUserId(String userId) {
        return integralService.findUserInegralByUserId(userId);
    }
    @GetMapping("/findUserInegralById")
    @InMethod(apiName = "获取用户积分")
    public ResultJson findUserInegralById() {
        User user = (User) SecurityUtils.getSubject().getSession().getAttribute("user");
        return integralService.findUserInegralByUserId(user.getId() +"");
    }

}
